home *** CD-ROM | disk | FTP | other *** search
/ Family Forum 261 / SOMC Family Forum 261.iso / Xtras / Behavior Library.cst / 00010_Script_Open Movie in a Window < prev    next >
Text File  |  1997-11-17  |  6KB  |  126 lines

  1. -- Movie in a Window    Open
  2.  
  3. -- behavior library version 1.1
  4.  
  5. -- Opens a Movie In a Window, a director file that runs alongside the current movie.
  6. -- Use with the "Message Movie In a Window" Behavior to control the MIAW
  7.  
  8. -- also functions through lingo by handling message 'initOpenMIAW', 
  9. -- for example if this behavior was assigned to sprite 5, use
  10. -- sendsprite 5, #initOpenMIAW
  11.  
  12. property  windowLeft, windowTop, windowWidth, windowHeight
  13. property  windowMovie, windowName, windowType
  14. property  scrollable, sizable, zoomable, invisible
  15. property  whichEvent
  16.  
  17. on initOpenMIAW me
  18.   init me
  19. end
  20.  
  21. on mouseUp me
  22.   if whichEvent = #mouseup    then init me
  23. end
  24.  
  25. on prepareFrame me
  26.   if whichEvent = #prepareframe then init me
  27. end
  28.  
  29. on exitFrame me
  30.   if whichEvent = #exitframe  then init me
  31. end
  32.  
  33. on init me
  34.   set w = get_previous_instance( the WindowList, the windowName of me )
  35.   -- dispose of window if already open
  36.   if objectP( w ) then
  37.     forget w 
  38.   end if
  39.   -- initialize from behavior parameters
  40.   if the windowName of me <> EMPTY then
  41.     set w = window the windowName of me
  42.     set the titleVisible of w = TRUE
  43.   else
  44.     set w = window "temp"
  45.     set the titleVisible of w = FALSE
  46.   end if
  47.   set the fileName of w = get_filename( the windowMovie of me )
  48.   set the windowType of w = get_window_style( me )
  49.   set the rect of w = rect( the windowLeft of me, the windowTop of me,                                    ( the windowLeft of me + the windowWidth  of me ),                                    ( the windowTop  of me + the windowHeight of me ))
  50.   open w
  51.   
  52. end
  53.  
  54. ---
  55.  
  56. on get_previous_instance w_list, w_name
  57.   repeat with i = count( w_list ) down to 1
  58.     set w = getAt( w_list, i )
  59.     if the name of w = w_name then 
  60.       return( w )
  61.     end if
  62.   end repeat
  63.   return( -1 )
  64. end
  65.  
  66. on get_window_style me
  67.   case ( the windowType of me ) of:
  68.     #Document:
  69.       if the zoomable of me then
  70.         if the sizable of me then 
  71.           set t = 8
  72.         else
  73.           set t = 12
  74.         end if
  75.       else  -- NOT zoomable
  76.         if the sizable of me then 
  77.           set t = 0
  78.         else
  79.           set t = 4
  80.         end if
  81.       end if
  82.       
  83.     #Palette: 
  84.       set t = 49
  85.     #Rounded: 
  86.       set t = 16
  87.     #Plain:   
  88.       set t = 2
  89.     #Shadow:  
  90.       set t = 3
  91.     #"Modal Dialog":  
  92.       set t = 1
  93.     #"Movable Modal Dialog":  
  94.       set t = 5
  95.     otherwise: set t = 4
  96.   end case
  97.   return( t )
  98. end
  99.  
  100. on get_filename f_name
  101.   -- don't force user to remember the extension
  102.   if NOT ( f_name contains ".dir" ) then
  103.     set f_name = f_name & ".dir"
  104.   end if
  105.   -- support relative pathnames
  106.   if (( f_name contains "/" ) OR       ( f_name contains "\" )) then
  107.     if ( NOT f_name contains ":" ) then
  108.       set f_name = the pathname & f_name
  109.     end if
  110.   end if
  111.   return( f_name )
  112. end
  113.  
  114. on getPropertyDescriptionList
  115.   
  116.   set p_list = [    #windowMovie: [ #comment:   "Movie Name:",                     #format:   #string,                    #default:    "" ],     #windowName: [ #comment:   "Window Name:",                     #format:   #string,                    #default:    "" ],    #windowType: [ #comment:   "Window Style:",                     #format:   #symbol,                      #range: [ #Document, #Palette, #Rounded, #Plain, #Shadow,                               #"Modal Dialog", #"Movable Modal Dialog" ],                    #default:    #Document ],        #sizable: [ #comment:   "Resize Box:",                     #format:   #boolean,                    #default:    FALSE ],     #windowLeft: [ #comment:   "Left:",                     #format:   #integer,                    #default:    100 ],      #windowTop: [ #comment:   "Top:",                     #format:   #integer,                    #default:    100 ],    #windowWidth: [ #comment:   "Width:",                     #format:   #integer,                    #default:    0 ],   #windowHeight: [ #comment:   "Height:",                     #format:   #integer,                    #default:    0 ],       #zoomable: [ #comment:   "Zoom Box:",                       #format:   #boolean,                      #default:    FALSE ],   #WhichEvent: [ #comment:   "Initializing Event:",                     #format:   #symbol,                      #range: [ #MouseUp, #PrepareFrame, #ExitFrame, #InitOpenMIAW],                    #default:   #MouseUp ]                  ]
  117.   return p_list 
  118.   
  119.   
  120.   
  121. end
  122.  
  123. on getBehaviorDescription
  124.    return "Opens a Director movie in a window of the designated type. This behavior can be triggered by a specified event or by receiving the initOpenMIAW message. If width and height parameters are set to 0 (the default), the movie opens at it's original size." & RETURN & "PARAMETERS:" & RETURN & "ò Movie Name - Enter the file name of the movie to be opened." & RETURN & "ò Window Name - ( optional ) Enter the label to be displayed in window header, when visible." & RETURN & "ò Window Style - Choose a border style and interactivity options. The choices are: Document (moveable, sizeable window without a zoom box), Palette (floating palette), Rounded (rounded corners), Plain (plain box, no title bar), Shadowed (plain box with shadow, no title bar), Modal Dialog, and Moveable Modal Dialog " & RETURN & "ò Resize Box - Turn this option on to make the window resizable when appropriate." & RETURN & "ò Left, Top - Enter the initial offset ( in pixels ) of the window from the upper left corner of the display." & RETURN & "ò Width, Height - ( optional ) Enter the initial dimensions ( in pixels ) of the window."  & RETURN & "ò Zoom Box - Turn this option on to add a minimize/maximize button to the title bar when appropriate." & RETURN & "ò Initializing Event - Choose the event that triggers the behavior. Choose initOpenMIAW to make the behavior run when it receives this message."
  125. end
  126.